package com.phz.springcloud.study.controller;

import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.phz.springcloud.study.entity.User;
import com.phz.springcloud.study.service.UserService;


@RestController
public class RegisterController {
	
	protected static final Logger logger = LoggerFactory.getLogger(RegisterController.class);
	
	@Autowired
	UserService userService;
	
	/**
	 * 用户注册
	 * @param user
	 * @return
	 */
	@RequestMapping("/register")
	public String register(@RequestBody User user) {
		userService.register(user);
		return "注册成功了";
	}
	
	@RequestMapping("/test")
	public String test() {
		try {
			Thread.sleep(7000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String uuid =  UUID.randomUUID().toString();
		logger.debug(uuid+"------------------");
		return uuid;
	}
	
	/**
	 * 用户结算
	 * @return
	 */
	@RequestMapping("/balance")
	public String balance() {
		String uuid =  UUID.randomUUID().toString();
		logger.debug(uuid+"------------------");
		return uuid;
	}

}
